package ar.com.fiuba.ElectronicCircuitAnalyst.domain.specs;

import java.util.List;

import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.Circuit;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.CircuitElement;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.api.Lead;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.common.Specification;

public class CircuitElementsSpecification implements Specification<Circuit> {

	public Boolean isSatisfiedBy(Circuit circuit) {
		
		List<CircuitElement> elements = circuit.getCircuitElements();
		
		for (CircuitElement element : elements){
			
			List<Lead> inputLeads = element.getInputLeads();
			for (Lead lead : inputLeads){
				if (!lead.isConnected()) return false; 
			}
			
		}
		return true;
	}

}
